//
//  shareView.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/20.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "shareView.h"
#import <Masonry.h>
@implementation shareView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupViews];
    }
    return self;
}

-(void)setupViews{
    self.backgroundColor = [UIColor whiteColor];
    
    self.topView = [[UIView alloc] init];
    UIImage *image = [UIImage imageNamed:@"share_bg"];
    self.topView.layer.contents = (id)image.CGImage;
    [self addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.height.equalTo(self.topView.mas_width).multipliedBy(0.42);
    }];
    
    self.nameLab = [[UILabel alloc] init];
    self.nameLab.text = @"王小白";
    self.nameLab.font = [UIFont boldSystemFontOfSize:20];
    self.nameLab.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    [self.topView addSubview:self.nameLab];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30);
        make.top.mas_equalTo(45);
    }];
    
    self.imv = [[UIImageView alloc] init];
    self.imv.image = [UIImage imageNamed:@"share_icon_tuiguangren"];
    [self.topView addSubview:self.imv];
    [self.imv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(10);
        make.centerY.equalTo(self.nameLab);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(50);
    }];
    
    self.totalLab = [[UILabel alloc] init];
    self.totalLab.text = @"推荐总人数";
    self.totalLab.font = [UIFont systemFontOfSize:16];
    self.totalLab.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1];
    [self.topView addSubview:self.totalLab];
    [self.totalLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab);
        make.top.equalTo(self.nameLab.mas_bottom).offset(18);
    }];
    
    self.totalNumLab = [[UILabel alloc] init];
    self.totalNumLab.text = @"10人";
    self.totalNumLab.font = [UIFont boldSystemFontOfSize:18];
    self.totalNumLab.textColor = [UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1];
    [self.topView addSubview:self.totalNumLab];
    [self.totalNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.totalLab.mas_right).offset(5);
        make.centerY.equalTo(self.totalLab);
    }];
    
    self.arrowImv = [[UIImageView alloc] init];
    self.arrowImv.image = [UIImage imageNamed:@"icon_arrow_purple_right"];
    [self.topView addSubview:self.arrowImv];
    [self.arrowImv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-35);
        make.centerY.equalTo(self.totalLab);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(16);
    }];
    
    self.myTeamBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.myTeamBtn setTitle:@"我的团队" forState:(UIControlStateNormal)];
    [self.myTeamBtn setTitleColor:[UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1] forState:(UIControlStateNormal)];
    self.myTeamBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.topView addSubview:self.myTeamBtn];
    [self.myTeamBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowImv.mas_left);
        make.centerY.equalTo(self.arrowImv);
    }];
    
    self.QRcodeImv = [[UIImageView alloc] init];
    self.QRcodeImv.image = [UIImage imageNamed:@"test"];
    [self addSubview:self.QRcodeImv];
    [self.QRcodeImv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom).offset(25);
        make.centerX.equalTo(self);
        make.width.mas_equalTo(148);
        make.height.mas_equalTo(148);
    }];
    
    self.inviteCodeLab = [[UILabel alloc] init];
    self.inviteCodeLab.text = @"邀请码";
    self.inviteCodeLab.font = [UIFont systemFontOfSize:14];
    self.inviteCodeLab.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1];
    [self addSubview:self.inviteCodeLab];
    [self.inviteCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.QRcodeImv.mas_bottom).offset(10);
    }];
    
    self.inviteCodeNumLab = [[UILabel alloc] init];
    self.inviteCodeNumLab.text = @"***";
    self.inviteCodeNumLab.font = [UIFont systemFontOfSize:14];
    self.inviteCodeNumLab.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1];
    [self addSubview:self.inviteCodeNumLab];
    [self.inviteCodeNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.inviteCodeLab.mas_bottom).offset(5);
    }];
    
    
    self.CCopyBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.CCopyBtn setTitle:@"复制" forState:(UIControlStateNormal)];
    [self.CCopyBtn setTitleColor:[UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1] forState:(UIControlStateNormal)];
    self.CCopyBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.CCopyBtn];
    [self.CCopyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.inviteCodeNumLab.mas_right).offset(10);
        make.centerY.equalTo(self.inviteCodeNumLab);
    }];
    
    self.sharebtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.sharebtn setTitle:@"分享赚收益" forState:(UIControlStateNormal)];
    [self.sharebtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.sharebtn.titleLabel.font = [UIFont systemFontOfSize:16];
    self.sharebtn.layer.cornerRadius = 20;
    self.sharebtn.backgroundColor = [UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1];
    [self addSubview:self.sharebtn];
    [self.sharebtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.inviteCodeNumLab.mas_bottom).offset(40);
        make.left.equalTo(self.QRcodeImv);
        make.right.equalTo(self.QRcodeImv);
        make.height.mas_equalTo(40);
    }];
    
    
}

@end
